package org.seven.jrdp.biz.t.service;

import java.util.List;

import org.seven.jrdp.biz.t.mapper.TZzMapper;
import org.seven.jrdp.biz.t.model.TZz;
import org.seven.jrdp.commons.model.Option;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class TZzService {
	@Autowired
	private TZzMapper tZzMapper;

	@Transactional(readOnly = true)
	public List<TZz> find() {
		Example example = new Example(TZz.class);
		example.orderBy("mc");
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("deleteFlag", "0");
		return tZzMapper.selectByExample(example);
	}

	@Transactional(readOnly = true)
	public TZz get(String id) {
		return tZzMapper.selectByPrimaryKey(id);
	}

	@Transactional
	public void insert(TZz tZz) {
		tZzMapper.insertSelective(tZz);
	}

	@Transactional
	public void update(TZz tZz) {
		tZzMapper.updateByPrimaryKeySelective(tZz);
	}

	@Transactional
	public void delete(String id) {
		TZz tZz = new TZz();
		tZz.setId(id);
		tZz.setDeleteFlag("1");
		tZzMapper.updateByPrimaryKeySelective(tZz);
	}

	@Transactional(readOnly = true)
	public List<Option> getOption() {
		return tZzMapper.getOption();
	}
}